<template>
    <div id="AsnDetailList">
        <v-tableTitle :btnConfig="btnConfig" :tableSelectData="selectData" @backList="backList"
                      ></v-tableTitle>
        <div class="detail">
            <v-navMenu
                    :detailNav="detailNav"
                    :menuData="menuData"
                    @setMentActive="setMentActive"
                    v-if="detailNav=='1'||detailNav=='2' ||detailNav=='3'"
            ></v-navMenu>
            <component :data="{detailData,argument,detailSelectData,type}" :is="currentComponent"></component>
        </div>
    </div>

</template>

<script>
    import tableTitle from "commons/TableTitle";
    import navMenu from "commons/NavMenu";
    import baseMixin from "@/mixins/BaseMixin";
    import config from "../Config"

    export default {
        name: "DetailList",
        mixins: [baseMixin, config],
        data() {
            return {
                newFlag: false,
                argument: {},
                detailData: {},
                selectData: [],
                menuData: [
                    {label: this.$t('out.skudetail'), index: "1"},
                    {label: this.$t('out.ship_carton'), index: "2"},
                    {label: this.$t('out.ymxfj'), index: "3"},
                ],
                detailNav: "1",
                saveType: "filter",
                componentConfig: [
                    {
                        name: "skudetail",
                        label: this.$t('out.skudetail'),
                        component: () => import('./page/skudetail.vue')
                    },
                    {
                        name: "casedetail",
                        label: this.$t('out.ship_carton'),
                        component: () => import('./page/casedetail.vue')
                    },
                    {
                        name: "ymxfj",
                        label: this.$t('out.ymxfj'),
                        component: () => import('./page/ymxfj.vue')
                    }
                ],
                detailSelectData: {},
                type: ""
            }
        },
        computed: {
            btnConfig() {
                return []
            },
            currentComponent() {
                return this.componentConfig[this.detailNav - 1].component;
            }
        },
        methods: {
            //选中的数据
            setSelectData(data) {
                this.selectData = data;
            },
            //导航值
            setMentActive(key) {
                this.detailNav = key;
                this.selectData = [];
            }
        },
        mounted() {
            
            this.newFlag = this.$store.state.newFlag;
            if (this.newFlag) {

            } else if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.argument = data.routeData;
                this.detailData = data.detailList;
                this.detailNav = data.detailListNav;
            } else {
                this.argument = this.$store.state.routeData;
            }

        },
        components: {
            "v-tableTitle": tableTitle,
            "v-navMenu": navMenu,
        },
        watch: {
            selectData(data) {
                if (this.permissionStatus) {
                    if (data.length > 0) {
                        this.deleteStatus = false;
                    } else {
                        this.deleteStatus = true;
                    }
                }
            }
        }
    }
</script>

<style>

</style>
